Fragmentation is a memory management issue in an operating system where memory space is wasted due to inefficient allocation. Even when sufficient memory is available, it may not be usable effectively because it is divided into small pieces.
Fragmentation occurs when memory is allocated and deallocated in such a way that free memory is broken into smaller non-contiguous blocks. This leads to poor memory utilization and reduced system performance.
Internal fragmentation happens when the allocated memory block is larger than the required memory. The unused space inside the allocated block is wasted and cannot be used by other processes.
Example: If a process requires 18 KB of memory but is allocated a block of 20 KB, then 2 KB remains unused.
Occurs In: Fixed partitioning, Paging
External fragmentation occurs when free memory is available in small scattered blocks. Although the total free memory is sufficient, it is not contiguous, so large processes cannot be allocated memory.
Example: Free memory blocks of 5 KB, 10 KB, and 15 KB exist, but a process needs 25 KB contiguously.
Occurs In: Variable partitioning, Segmentation
| Feature | Internal Fragmentation | External Fragmentation |
|---|---|---|
| Wasted Space | Inside allocated memory block | Between allocated memory blocks |
| Cause | Fixed-size allocation | Non-contiguous free memory |
| Occurs In | Paging, Fixed partitioning | Segmentation, Variable partitioning |
| Solution | Smaller block size | Compaction, Paging |
Fragmentation is a condition in an operating system where memory is wasted due to inefficient allocation, resulting in unused memory spaces.